package cn.kgc.springboot.controller;

import cn.kgc.springboot.entity.Score;
import cn.kgc.springboot.http.ResponseResult;
import cn.kgc.springboot.service.ScoreService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author 课工场
 * @date 2025/1/10
 * @description 数据可视化模块 控制层
 */
@RestController
@RequestMapping("dataVisual")
@CrossOrigin
public class DataVisualController {

    @Resource
    private ScoreService scoreService;

    // 获取学生考试成绩
    @GetMapping("score")
    public ResponseResult scoreVisual() {

        List<Score> scores = scoreService.list();
        return  ResponseResult.success().data("scores",scores);
    }


    @GetMapping("student")
    public ResponseResult studentVisual() {

         List<Map<String,Object>> studentNumber = scoreService.studentNumber();
        return  ResponseResult.success().data("studentNumber",studentNumber);

    }

}
